home *** CD-ROM | disk | FTP | other *** search
- Path: ssc.sas.upenn.edu!modavis
- From: modavis@ssc.sas.upenn.edu (Morris A. Davis)
- Newsgroups: comp.lang.c++
- Subject: Re: Borland Addition
- Date: 14 Feb 1996 18:29:25 GMT
- Organization: University of Pennsylvania
- Message-ID: <4ft9m5$fsr@netnews.upenn.edu>
- References: <2d7cc$14c35.82@NEWS>
- NNTP-Posting-Host: ssc.sas.upenn.edu
- X-Newsreader: TIN [version 1.2 PL2-upenn1.3]
-
- Gooseman () wrote:
- : I just saw an interesting bug in "Windows Developer" magazine (I think
- : that's the title).
-
- : #include <iostream.h>
- : int main()
- : {
- : int i = 1;
- : int j = 1;
-
- : if(i)
- : i = i + 4;
- : else
- : i = j + 4;
-
- : cout << i;
- : }
-
- : You would expect the output to be 5, but the result will be 9! I
- : tried this under 4.52 and 4.0 and both produced the same results.
-
- First, I set the target to Easy Win...
- I tried this in my Borland 4.52, and I got the same result (9). When I
- changed the line
- i=i+4;
- to
- i+=4;
- I got the correct result, 5
-
- However, if you change the target to Win32 (and remember to add return
- 0; at the end of the program), with the i=i+4; line (as well as with the
- i+=4; line), you get the correct result (5). This was with the
- "Console" option of Win32.
-
- Curious.
-
- Morris Davis
-